package com.cy.duosearch.langchain.tool;


import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Objects;

public class JsonUtil {
    private static final ObjectMapper objectMapper = new ObjectMapper();

    private JsonUtil(){

    }

    public static <T> T jsonToObject(String str, Class<T> clazz) {
        if(Objects.isNull(str) || str.isEmpty()) return null;

        try{
            return objectMapper.readValue(str, clazz);
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }




}

